package com.googlecode.pdfToCMaker;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ayacub on 12/5/13.
 */
public class PDFUtilTestHelper  {

    public static File readFile(String path, String name) throws IOException {
        InputStream stream = PDFUtilTestHelper.class.getClassLoader().getResourceAsStream(path);
        File file = File.createTempFile(name, ".pdf");
        file.deleteOnExit();
        FileUtils.copyInputStreamToFile(stream, file);
        return file;
    }

    public static List<File> getSomePDFs() throws IOException {
        File aFile = readFile("a.pdf", "hello");
        File bFile = readFile("b.pdf", "goodbye");
        List<File> input = new ArrayList<File>();
        input.add(aFile);
        input.add(bFile);
        return input;
    }

    public static List<TOCEntry> getSomePDFsAsTOC() throws IOException {
        File aFile = readFile("a.pdf", "hello");
        File bFile = readFile("b.pdf", "goodbye");
        List<TOCEntry> ret = new ArrayList<TOCEntry>();
        ret.add(new TOCHeading("heading"));
        ret.add(new TOCEntry("a", aFile));
        ret.add(new TOCEntry("b", bFile));
        return ret;
    }
}
